]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shellMountOperation: Don't read unavailable desktop file
authorBalló György <ballogyor@gmail.com>
Thu, 2 Feb 2023 07:26:20 +0000 (07:26 +0000)
committerBalló György <ballogyor@gmail.com>
Thu, 2 Feb 2023 18:33:10 +0000 (19:33 +0100)
If gnome-disk-utility is not installed on the system, its desktop file is
unavailable, so we can't get the application's name. In this case hide
the launcher button.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2621>

js/ui/shellMountOperation.js

index b04156d1e04bf450b8d65de5d16b24f645fc74a0..00498763b7b6cb27bbb0fef19b0ff895effdb238 100644 (file)
@@ -294,10 +294,15 @@ var ShellMountPasswordDialog = GObject.registerClass({
             content.add_child(this._keyfilesCheckbox);
 
             this._keyfilesLabel = new St.Label({ visible: false });
-            this._keyfilesLabel.clutter_text.set_markup(
-                /* Translators: %s is the Disks application */
-                _('To unlock a volume that uses keyfiles, use the <i>%s</i> utility instead.')
-               .format(disksApp.get_name()));
+            if (disksApp) {
+                this._keyfilesLabel.clutter_text.set_markup(
+                    /* Translators: %s is the Disks application */
+                    _('To unlock a volume that uses keyfiles, use the <i>%s</i> utility instead.')
+                   .format(disksApp.get_name()));
+            } else {
+                this._keyfilesLabel.clutter_text.set_markup(
+                    _('You need an external utility like <i>Disks</i> to unlock a volume that uses keyfiles.'));
+            }
             this._keyfilesLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
             this._keyfilesLabel.clutter_text.line_wrap = true;
             content.add_child(this._keyfilesLabel);
@@ -387,13 +392,20 @@ var ShellMountPasswordDialog = GObject.registerClass({
             label: _("Cancel"),
             action: this._onCancelButton.bind(this),
             key: Clutter.KEY_Escape,
-        }, {
-            /* Translators: %s is the Disks application */
-            label: _("Open %s").format(disksApp.get_name()),
-            action: this._onOpenDisksButton.bind(this),
-            default: true,
         }];
 
+        if (disksApp) {
+            this._usesKeyfilesButtons.push({
+                /* Translators: %s is the Disks application */
+                label: _('Open %s').format(disksApp.get_name()),
+                action: () => {
+                    disksApp.activate();
+                    this._onCancelButton();
+                },
+                default: true,
+            });
+        }
+
         this.setButtons(this._defaultButtons);
     }
 
@@ -455,20 +467,6 @@ var ShellMountPasswordDialog = GObject.registerClass({
         this._keyfilesLabel.visible = useKeyfiles;
         this.setButtons(useKeyfiles ? this._usesKeyfilesButtons : this._defaultButtons);
     }
-
-    _onOpenDisksButton() {
-        let app = Shell.AppSystem.get_default().lookup_app('org.gnome.DiskUtility.desktop');
-        if (app) {
-            app.activate();
-        } else {
-            Main.notifyError(
-                /* Translators: %s is the Disks application */
-                _("Unable to start %s").format(app.get_name()),
-                /* Translators: %s is the Disks application */
-                _('Couldn’t find the %s application').format(app.get_name()));
-        }
-        this._onCancelButton();
-    }
 });
 
 var ShellProcessesDialog = GObject.registerClass({